#pragma once
#include <iomanip>
#include <iostream>
#include <map>
#include <opencv2/imgproc.hpp>
#include <vector>

#include "yolov7.h"

// 返回的警报框
struct alertRect {
    cv::Point left_up_point;     // 存储矩形框左上角点
    cv::Point right_down_point;  // 存储矩形框右下角点
    long long last_gather_time;  // 上次发生人员聚集的时间
    long long last_alert_time;   // 上次发送聚集警报的时间
    bool rect_is_store;
};
// 需要进行聚类的点
struct ClusterPoint {
    cv::Point point_position;
    int cluster;
    bool visited;
};

class PeopleGather {
   public:
    PeopleGather();
    PeopleGather(int distance_between_target, int target_around_number, int judge_peoplesqueeze_number);
    std::map<int, alertRect> alert_rects;                                                                       // 存储报警框
    void Alert_Detect(std::vector<BoxInfo> detect_box);                                                         // 警报检测
    void Draw_All_AlertRect(cv::Mat detect_image);                                                              // 画出全部聚集框
    void Draw_Single_AlertRect(cv::Mat detect_image, int rect_id, cv::Scalar rect_color);                       // 画出单个聚集框 不给出时间
    void Draw_Single_AlertRect(cv::Mat detect_image, int rect_id, cv::Scalar rect_color, long long timestamp);  // 画出单个聚集框 给出时间
    long long Get_Current_Timestamp();                                                                          // 获取当前时间戳
   private:
    int distance_between_target;     // 一个点包含其他点最大的距离
    int target_around_number;        // 一个点包含其他点最小个数
    int judge_peoplesqueeze_number;  // 框内多少数判断为聚集
    int rect_id;                     // 框的id
};
